python函数

您所在的位置:网站首页 python isupper函数 python函数

python函数

2023-10-09 02:57| 来源: 网络整理| 查看: 265

文章目录 1. isupper() 判断是否全是大写2. islower()判断是否全是小写3. istitle()判断首字母是否大写, 其余的是否小写

python函数 系列目录:python函数——目录

字符串字母大小写转换: python函数——字符串字母大小写转换

Python提供了isupper(),islower(),istitle()方法用来判断字符串的大小写, 具体实例如下:

>>> str_1 = "HELLO PYTHON" # 全大写 >>> str_2 = "Hello PYTHON" # 大小写混合 >>> str_3 = "Hello Python" # 单词首字母大写 >>> str_4 = "hello python" # 全小写 1. isupper() 判断是否全是大写 >>> str_1.isupper() True >>> str_2.isupper() False >>> str_3.isupper() False >>> str_4.isupper() False 2. islower()判断是否全是小写 >>> str_1.islower() False >>> str_2.islower() False >>> str_3.islower() False >>> str_4.islower() True 3. istitle()判断首字母是否大写, 其余的是否小写 >>> str_1.istitle() False >>> str_2.istitle() False >>> str_3.istitle() True >>> str_4.istitle() False


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3